<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:61:"/www/jilly/public/../application/view/admin/weapp/config.html";i:1539678971;s:45:"/www/jilly/application/view/layout/admin.html";i:1541172698;s:29:"static/html/admin_header.html";i:1542980281;s:29:"static/html/admin_footer.html";i:1542962976;}*/ ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="”Cache-Control”" content="”no-transform”">
    <meta http-equiv="”Cache-Control”" content="”no-siteapp”">
    <!-- 百度收录start -->
    <meta name="baidu-site-verification" content="fBCVU8Appn" />
    <!-- 百度收录end -->
    <meta name="keywords" content="Dink、QQ三国">
    <meta name="description" content="最业余的saas管理平台">
    <title><?php echo (isset($title) && ($title !== '')?$title:'Jilly的小宇宙'); ?></title>
    <link rel="stylesheet" type="text/css" href="/static/js/dink/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/static/js/dink/dink.css" />
    <script type="text/javascript" src="/static/js/dink/jquery.js"></script>
    <script type="text/javascript" src="/static/js/dink/pjax.js"></script>
    <script type="text/javascript" src="/static/js/dink/layui/layui.all.js"></script>
    <script type="text/javascript" src="/static/js/dink/layui/layui.js"></script>
    <script type="text/javascript" src="/static/js/dink/dink.js"></script>
    <script type="text/javascript" src="/static/js/dink/public.js"></script>
    <!--loading-->
    <style>
        .loading{-webkit-animation:transform-5 2s ease 500ms alternate none 1;animation:transform-5 500ms ease 500ms alternate none 1;}
        @-webkit-keyframes transform-5 {
            from{-webkit-transform:perspective(400px) rotateY(180deg);transform:perspective(400px) rotateY(180deg);}
            to{-webkit-transform:perspective(400px) rotateY(0deg);transform:perspective(400px) rotateY(0deg);}
        }
        @keyframes transform-5 {
            from{-webkit-transform:perspective(400px) rotateY(180deg);transform:perspective(400px) rotateY(180deg);}
            to{-webkit-transform:perspective(400px) rotateY(0deg);transform:perspective(400px) rotateY(0deg);}
        }
    </style>
    <!--loading-->
</head>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo" style="cursor:pointer;"><?php echo PN; ?>后台管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="">控制台</a></li>
            <li class="layui-nav-item"><a href="">商品管理</a></li>
            <li class="layui-nav-item">
                <a href="javascript:;">其它系统</a>
                <dl class="layui-nav-child">
                    <dd><a href="">邮件管理</a></dd>
                    <dd><a href="">消息管理</a></dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="">控制台<span class="layui-badge">9</span></a>
            </li>
            <li class="layui-nav-item">
                <a href="">个人中心<span class="layui-badge-dot"></span></a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="/static/img/index/favicon.ico" class="layui-nav-img">
                    <?php echo \think\Session::get('userInfo.nickname'); ?>
                </a>
                <dl class="layui-nav-child layui-anim layui-anim-upbit">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a id="logout" href="javascript:;">注销</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree">
                <!--遍历菜单start-->
                <?php foreach(\think\Session::get('sideMenu') as $value): ?>
                <li class="layui-nav-item">
                    <?php if(( (\think\Session::get('userInfo.permission') && in_array($value['permission'],\think\Session::get('userInfo.permission'))) || \think\Session::get('userInfo.role_id')==0 )): ?>
                    <a data-pjax href="<?php echo $value['href']; ?>" data-title="<?php echo $value['title']; ?>">
                        <?php echo $value['title'];?>
                    </a>
                    <?php endif; if(isset($value['menu'])){  ?>
                    <dl class="layui-nav-child">
                        <?php foreach($value['menu'] as $val): if(( (\think\Session::get('userInfo.permission') && in_array($val['permission'],\think\Session::get('userInfo.permission'))) || \think\Session::get('userInfo.role_id')==0 )): ?>
                        <dd><a data-pjax href="<?php echo $val['href']; ?>" data-title="<?php echo $val['title']; ?>"><?php echo $val['title']; ?></a></dd>
                        <?php endif; endforeach; ?>
                    </dl>
                    <?php  }  ?>
                </li>
                <?php endforeach; ?>
                <!--遍历菜单end-->
            </ul>
        </div>
    </div>

    <!--loading-->

    <!--loading-->

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;" id="dink-container">
            <!--主体页面-->

            <!--end-->


<script>
    $(function(){
        $(document).pjax('a[data-pjax]','#dink-container');
        $.pjax.reload('#dink-container')

        //pjax前后操作
        $(document).on('pjax:send',function(){
            // $('.layui-body').addClass('loading');
        });
        $(document).on('pjax:success',function(){
            // setTimeout(function(){
            //     $('.layui-body').removeClass('loading');
            // },1000);
            $('dd').removeClass('layui-this');
            var long = location.href;
            var short = location.hostname;
            var now = long.substr(long.indexOf(short)+short.length);
            $('dd').each(function(){
                var url = $(this).find('a').attr('href');
                if(url == now){
                    $(this).parents('.layui-nav-item').addClass('layui-nav-itemed');
                    $(this).addClass('layui-this');
                    $('title').text($(this).find('a').attr('data-title'));
                }
            });
        });

        //浏览器前后操作
        $(document).on('pjax:start',function(){
            // $('.layui-body').addClass('loading');
        });
        $(document).on('pjax:end', function() {
            // setTimeout(function(){
            //     $('.layui-body').removeClass('loading');
            // },1000);
            $('dd').removeClass('layui-this');
            var long = location.href;
            var short = location.hostname;
            var now = long.substr(long.indexOf(short)+short.length);
            $('dd').each(function(){
                var url = $(this).find('a').attr('href');
                if(url == now){
                    $(this).parents('.layui-nav-item').addClass('layui-nav-itemed');
                    $(this).addClass('layui-this');
                    $('title').text($(this).find('a').attr('data-title'));
                }
            });
        });

        SideMenu();
    });

    //监听子菜单点击
    $(document).on('click','dd',function(){
        $('dd').removeClass('layui-this');
        $(this).parents('.layui-nav-item').addClass('layui-nav-itemed');
        $(this).addClass('layui-this');
        $('title').text($(this).find('a').attr('data-title'));
    });

    //菜单根据页面选中
    function SideMenu(){
        var now = '/'+'<?php echo current_url(); ?>';
        $('dd').each(function(){
            var url = $(this).find('a').attr('href');
            if(url == now){
                $(this).parents('.layui-nav-item').addClass('layui-nav-itemed');
                $(this).addClass('layui-this');
                $('title').text($(this).find('a').attr('data-title'));
            }
        });
    }

    //注销
    $(document).on('click','#logout',function(){
        var url = '/handler/login/doLogout';
        var data = {};
        $.post(url,data,function(e){
            if(e.ret == 1){
                location.reload();
            }else{
                layer.msg(e.msg);
            }
        },'json');
    });

    //跳转首页
    $('.layui-logo').click(function(){
        location.href = '/admin/index';
    });

</script>
<style>
    i{font-size:15px;color:#e0e0e0;margin-left:10px;cursor:pointer;
        border:1px solid #fff;padding:2px;}
    i:hover{color:#1E9FFF;}
    i2{font-size:15px;color:#e0e0e0;margin-left:10px;cursor:pointer;
        border:1px solid #fff;padding:2px;}
    .disabled{background:#e6e6e6;}
    label{width:100px!important;}
    .layui-input-block{margin-left:150px;}
    .auth{color:#84D945;}
</style>

<div class="layui-form">

    <div class="layui-form-item layui-col-md6">
        <label class="layui-form-label">URL验证<i2 class="layui-icon is_auth1 auth">&#xe672;</i2></label>
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm layui-btn-disabled is_auth2" style="margin-top:5px;">已验证</button>
        </div>
    </div>

    <div class="layui-form-item layui-col-md6">
        <label class="layui-form-label">开发者ID<i class="layui-icon">&#xe642;</i></label>
        <div class="layui-input-block">
            <input type="text" name="client_id" autocomplete="off" class="layui-input disabled" disabled>
        </div>
    </div>

    <div class="layui-form-item layui-col-md6">
        <label class="layui-form-label">开发者密码<i class="layui-icon">&#xe642;</i></label>
        <div class="layui-input-block">
            <input type="text" name="client_secret" autocomplete="off" class="layui-input disabled" disabled>
        </div>
    </div>

    <div class="layui-form-item layui-col-md6">
        <label class="layui-form-label">Token<i class="layui-icon">&#xe642;</i></label>
        <div class="layui-input-block">
            <input type="text" name="token" autocomplete="off" class="layui-input disabled" disabled>
        </div>
    </div>

    <div class="layui-form-item layui-col-md6">
        <label class="layui-form-label">AESKey<i class="layui-icon">&#xe642;</i></label>
        <div class="layui-input-block">
            <input type="text" name="encode_key" autocomplete="off" class="layui-input disabled" disabled>
        </div>
    </div>

</div>

<script>
    var configs;
    $(function(){
        layui.use('form');
        //获取config参数列表
        GetConifgList();
    });

    //获取config参数列表
    function GetConifgList(){
        var need = 'client_id,client_secret,auth,token,encode_key';
        dink.post('/handler/weapp/getConfigList',{need:need},function(res){
            if(res.ret == 1){
                configs = res.data;
                //设置验证状态
                SetAuth();
                $.each(res.data,function(i,ele){
                    $('input[name='+i+']').val(ele);
                });
            }else{
                layer.msg(res.msg);
            }
        });
    }

    //编辑按钮事件
    dink.click('i',function(){
        $(this).parent().next().children().attr('disabled',false);
        $(this).parent().next().children().removeClass('disabled');
        $(this).parent().next().children().focus();
    });

    //编辑完事件
    $('.layui-input').blur(function(){
        var that = $(this);
        if(configs[that.attr('name')] !== that.val()){
            layer.confirm('确定提交修改？',{title:'Tips'},function(){
                var title = that.attr('name');
                var content = that.val();
                dink.post('/handler/weapp/editConfig',{title:title,content:content},function(res){
                    layer.msg(res.msg);
                    if(res.ret == 1){
                        LockInput(that);
                    }
                });
            },function(){
                LockInput(that);
            });
        }else{
            LockInput(that);
        }
    });

    //锁定input并重新获取数据
    function LockInput(e){
        e.attr('disabled',true);
        e.addClass('disabled');
        GetConifgList();
    }

    //设置验证状态
    function SetAuth(){
        if(configs.auth == 1){
            $('.is_auth1').addClass('auth');
            $('.is_auth2').removeClass('layui-btn-normal');
            $('.is_auth2').addClass('layui-btn-disabled');
            $('.is_auth2').text('已验证');
        }else{
            $('.is_auth1').removeClass('auth');
            $('.is_auth2').removeClass('layui-btn-disabled');
            $('.is_auth2').addClass('layui-btn-normal');
            $('.is_auth2').text('点击验证');
        }
    }

    //url验证事件
    dink.click('.is_auth2',function(){
        if($(this).text() == '点击验证'){
            dink.post('/handler/weapp/test',{},function(res){
                // dink.post('/handler/weapp/auth',{},function(res){
                layer.msg(res.msg);
                // GetConifgList();
            });
        }
    });
</script>
</div>
</div>

<div class="layui-footer" align="center">
    <!-- 底部固定区域 -->
    © dink.xyz - <?php echo PN; ?>后台管理系统
</div>
</div>
</body>
</html>